<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\Relations\BelongsTo;

/**
 * @property int $id 
 * @property int $goods_id 
 * @property string $goods_name 
 * @property string $order_no 
 * @property int $num 
 * @property float $price 
 * @property float $original_price 
 * @property float $discount_price 
 * @property int $integral 
 * @property int $sku_id 
 * @property string $sku_name 
 * @property string $sku_picture 
 * @property float $sku_weight 
 */
class OrderItem extends Model
{
    public $timestamps = false;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'order_items';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'goods_id' => 'integer', 'num' => 'integer', 'price' => 'float', 'original_price' => 'float', 'discount_price' => 'float', 'integral' => 'integer', 'sku_id' => 'integer', 'sku_weight' => 'float'];

    /**
     * 商品模型关联
     *
     * @return BelongsTo
     */
    public function goods() :BelongsTo
    {
        return $this->belongsTo(Goods::class, 'goods_id', 'id');
    }

    /**
     * 商品 SKU 模型关联
     *
     * @return BelongsTo
     */
    public function goodsSku() :BelongsTo
    {
        return $this->belongsTo(GoodsSku::class, 'sku_id', 'id');
    }

    /**
     * 订单模型关联
     *
     * @return BelongsTo
     */
    public function order() :BelongsTo
    {
        return $this->belongsTo(Order::class, 'order_no', 'order_no');
    }

}